#define _CRT_SECURE_NO_WARNINGS 1

#include <stdio.h>
#include <string.h>
#include <assert.h>


//int main()
//{
//	char str1[20];
//	char str2[20];
//	strcpy(str1, "To be ");
//	strcpy(str2, "or not to be");
//	strncat(str1, str2, 5);
//	puts(str1);
//	return 0;
//}



char* my_strncpy(char* arr1, char* arr2, int n)
{
	assert(arr1 && arr1);
	char* ret = arr1;
	int len = strlen(arr2);
	int len1 = len;
	if (n <= len)
	{
		while (n)
		{
			*arr1 = *arr2;
			arr1++;
			arr2++;
			n--;
		}
		*(arr1) = '\0';
	}
	else
	{
		while (len)
		{
			*arr1 = *arr2;
			arr1++;
			arr2++;
			len--;

		}
		int k = n - len1;
		while (k)
		{
			*arr1 = '0';
			arr1++;
			k--;
		}
		*(arr1) = '\0';
	}
	return ret;
}

char* my_strncat(char* arr1, char* arr2, int n)
{
	assert(arr1 && arr2);
	char* ret = arr1;

	while (*arr1)
	{
		*arr1++;
	}

	while (n)
	{
	  *arr1 = *arr2;
	  arr1++;
	  arr2++;
	  n--;
	}
	return ret;
}

//int main()
//{
//	char arr1 [30] = "abc";
//	char arr2[30] = "abcdefg";
//    char *ret = my_strncat(arr1,arr2,9);
//    printf("%s\n",ret);
//	return 0;
//}